<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions">
    <ui:composition template="/layout/masterPageMain.xhtml">
          <f:metadata>
            
            <f:event type="preRenderView" listener="#{sys_NguoiDungController.onPageLoad_CheckAdmin_Edit()}">
                
            </f:event>
        </f:metadata>
         <ui:define name="ui-header">
             <title>DANH SÁCH TÀI KHOẢN</title>
        </ui:define>
        
        
        <ui:define name="ui-content">
            
            <h:form id="frmuserreport">
                <c:set var="vuser" value="#{sys_NguoiDungController.findAllUsers()}" scope="session"/>
                
            

                 <div class="panel panel-sea margin-bottom-40" style="border-color: #A52A2A">
                     <div class="panel-heading" style="background-color: #A52A2A;border-color: #A52A2A">
                        <h3 class="panel-title" style="text-align: center;background-color: #A52A2A">DANH SÁCH TÀI KHOẢN</h3>
                    </div>
                     
                     <div class="row" style="text-align: center;">
                            <a href="javascript:void(0)" style="margin-right: 3px;margin-top: 3px;" onclick="TaoMoiUser('1');" class="btn-u">Tạo Admin</a>
                            <a href="javascript:void(0)"  style="margin-right: 3px;margin-top: 3px;" onclick="TaoMoiUser('2');" class="btn-u">Tạo CP</a>
                     </div>
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>Tên tài khoản</th>
                                <th>Nhóm</th>
                                <th>Diễn giải</th>
                                <th>#</th>
                                <th>
                                    Trạng thái
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <c:forEach items="#{vuser}" var="item">
                                <tr>
                                    
                                    <td>#{item.getUserID()}</td>
                                     <td>#{item.isAdmin?"Admin":"CP"}</td>
                                     <td>#{item.descr}</td>
                                      <td>
                                          <button class="btn btn-primary btn-xs" type="button" onclick="Update_Users_Click('#{item.getId()}');"><i class="fa fa-truck-o"></i>Edit</button>
                                          <button class="btn btn-danger btn-xs" onclick="Delete_Users_Click('#{item.getId()}','Có chắc bạn muốn xóa dữ liệu?');" type="button"><i class="fa fa-trash-o"></i> Delete</button>
                                          
                                      </td>
                                     <td>
                                         <c:choose>
                                             <c:when test="#{item.isTrangThai()}">
                                                 <input id="#{item.getId()}" name="checkIds" checked="checked" type="checkbox"/>
                                             </c:when>
                                             <c:otherwise>
                                                 <input id="#{item.getId()}" name="checkIds" type="checkbox"/>
                                             </c:otherwise>
                                         </c:choose>
                                         
                                     </td>
                                </tr>
                                
                            </c:forEach>
                            
                            
                        </tbody>
                        <tfoot style="text-align: center">
                            <tr>
                                <td colspan="5">
                                    <a href="javascript:void(0)"  style="margin-right: 3px;margin-top: 3px;" onclick="CapNhatDanhSachTaiKhoan();" class="btn-u">Cập nhật</a>
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
                <p:remoteCommand name="Delete_UserReport" actionListener="#{sys_NguoiDungController.btnDelete_Click}" update=":frmuserreport"></p:remoteCommand>
                <p:remoteCommand name="Update_UserReport" actionListener="#{sys_NguoiDungController.btnUpdate_Click}" update=":frmuserreport"></p:remoteCommand>
                
                <p:remoteCommand name="cmd_New_User" actionListener="#{sys_NguoiDungController.btnNew_Click}" update=":frmuserreport"></p:remoteCommand>
                
                <p:remoteCommand name="Update_TrangThai_NguoiDung" actionListener="#{sys_NguoiDungController.btnCapNhatTrangThai_Click}" update=":frmuserreport"></p:remoteCommand>
            </h:form>
        </ui:define>
    </ui:composition> 
</html>